<?php

declare(strict_types=1);

namespace App\Logic\Admin\User;

use App\Dto\Admin\Test\TestBodyDto;
use App\Repository\Mysql\User\UserRepository;
use App\Vo\DataSubmitVo;
use Hyperf\DbConnection\Db;
use Hyperf\Di\Annotation\Inject;

class UserLogic
{
    #[Inject]
    protected UserRepository $repository;


    /**
     * Notes: 新增
     * User: tc
     * DateTime: 2024/12/21 10:55
     *
     */
    public function add(TestBodyDto $dto){
        $params = get_object_vars($dto);
        //开启事务
        try{
            if(!empty($params['create_date'])){
                $params['create_time'] = $params['create_date'];
            }
            $this->repository->init($params);
            $this->repository->insert($params);
        }catch (\Throwable $e) {
            var_dump($e->getMessage());
        }
        $vo = new DataSubmitVo();
        $vo->result = true;
        return $vo;
    }



}
